// var o;
// exports.OnlineGiftConfig = void 0;
// var AL_GAME_HUA_Instance = require("./AL_GAME_HUA_Instance");
// var AL_GAME_HUA_OnlineGiftData = require("./AL_GAME_HUA_OnlineGiftData");
// var AL_GAME_HUA_GameConst = require("./AL_GAME_HUA_GameConst");
// var c = (function (e) {
//     function t() {
//         var t = e.call(this) || this;
//         t.giftTime = -1;
//         t.recordTime = 0;
//         AL_GAME_HUA_Instance.Instance.tianjia_jishiqi(function (e) {
//             t.gengxin_shijian(e);
//         });
//         var n = t;
//         cc.game.on(
//             cc.game.EVENT_HIDE,
//             function () {
//                 if (n) {
//                     n.baocun_shijian_jilu();
//                 }
//             },
//             t
//         );
//         return t;
//     }
//     __extends(t, e);
//     t.getInstance = function () {
//         return this.instance || (this.instance = new t());
//     };
//     t.prototype.destroy = function () {
//         cc.game.targetOff(this);
//         t.instance = null;
//     };
//     t.prototype.huoqu_zaixian_jiangli_shifou_keyong = function () {
//         var e = AL_GAME_HUA_GameConst.GameConst.getInstance();
//         var t = AL_GAME_HUA_OnlineGiftData.OnlineGiftData.getInstance().huoqu_jieshou_cishu();
//         return e.online_enabled && (-1 == e.online_time_limit || t < e.online_time_limit);
//     };
//     t.prototype.huoqu_xuyao_shijian = function () {
//         var e = AL_GAME_HUA_OnlineGiftData.OnlineGiftData.getInstance().huoqu_jieshou_cishu();
//         var t = AL_GAME_HUA_GameConst.GameConst.getInstance();
//         var n = t.online_time_increase;
//         return t.online_time_origin + e * n;
//     };
//     t.prototype.huoqu_zaixian_jiangli_shifou_jiesuo = function () {
//         return AL_GAME_HUA_OnlineGiftData.OnlineGiftData.getInstance().huoqu_liwu_shifou_jiesuo();
//     };
//     t.prototype.shezhi_zaixian_jiangli_jiesuo = function (e) {
//         AL_GAME_HUA_OnlineGiftData.OnlineGiftData.getInstance().shezhi_liwu_shifou_jiesuo(e);
//         this.giftTime = this.huoqu_xuyao_shijian();
//     };
//     t.prototype.chuli_lingqu = function () {
//         AL_GAME_HUA_OnlineGiftData.OnlineGiftData.getInstance().tianjia_jieshou_cishu();
//         this.giftTime = 0;
//     };
//     t.prototype.huoqu_zaixian_jiangli_rule = function () {
//         return 0 == AL_GAME_HUA_OnlineGiftData.OnlineGiftData.getInstance().huoqu_jieshou_cishu()
//             ? [1, 1, 1, 1, 100]
//             : [2, 2, 2, 2, 200];
//     };
//     t.prototype.baocun_shijian_jilu = function () {};
//     t.prototype.huoqu_shengyu_shijian = function () {
//         return this.huoqu_xuyao_shijian() - this.giftTime;
//     };
//     t.prototype.gengxin_shijian = function (e) {
//         if (this.huoqu_zaixian_jiangli_shifou_keyong()) {
//             if (-1 == this.giftTime) {
//                 this.giftTime = AL_GAME_HUA_OnlineGiftData.OnlineGiftData.getInstance().huoqu_shijian_jilu();
//             }
//             if (this.huoqu_zaixian_jiangli_shifou_jiesuo()) {
//                 return void (this.giftTime = this.huoqu_xuyao_shijian());
//             }
//             this.giftTime < this.huoqu_xuyao_shijian()
//                 ? ((this.giftTime += e), (this.recordTime += e), this.recordTime >= 10 && this.baocun_shijian_jilu())
//                 : (this.giftTime != this.huoqu_xuyao_shijian() && (this.giftTime = this.huoqu_xuyao_shijian()),
//                   this.huoqu_zaixian_jiangli_shifou_jiesuo() || this.shezhi_zaixian_jiangli_jiesuo(!0),
//                   AL_GAME_HUA_OnlineGiftData.OnlineGiftData.getInstance().huoqu_shijian_jilu() != this.giftTime &&
//                       this.baocun_shijian_jilu());
//         }
//     };
//     t.instance = null;
//     return t;
// })(require("./AL_GAME_HUA_ConfigHandler").ConfigHandler);
// exports.OnlineGiftConfig = c;

// 引入所需模块
var AL_GAME_HUA_Instance = require("./AL_GAME_HUA_Instance");
var AL_GAME_HUA_OnlineGiftData = require("./AL_GAME_HUA_OnlineGiftData");
var AL_GAME_HUA_GameConst = require("./AL_GAME_HUA_GameConst");

// 定义 OnlineGiftConfig 类，继承自 ConfigHandler
class OnlineGiftConfig extends require("./AL_GAME_HUA_ConfigHandler").ConfigHandler {
    constructor() {
        super();
        this.giftTime = -1;
        this.recordTime = 0;

        AL_GAME_HUA_Instance.Instance.tianjia_jishiqi((elapsedTime) => {
            this.gengxin_shijian(elapsedTime);
        });

        cc.game.on(
            cc.game.EVENT_HIDE,
            () => {
                this.baocun_shijian_jilu();
            },
            this
        );
    }

    static getInstance() {
        if (!this.instance) {
            this.instance = new OnlineGiftConfig();
        }
        return this.instance;
    }

    destroy() {
        cc.game.targetOff(this);
        OnlineGiftConfig.instance = null;
    }

    huoqu_zaixian_jiangli_shifou_keyong() {
        const gameConst = AL_GAME_HUA_GameConst.GameConst.getInstance();
        const receiveCount = AL_GAME_HUA_OnlineGiftData.OnlineGiftData.getInstance().huoqu_jieshou_cishu();
        return gameConst.online_enabled && (gameConst.online_time_limit === -1 || receiveCount < gameConst.online_time_limit);
    }

    huoqu_xuyao_shijian() {
        const receiveCount = AL_GAME_HUA_OnlineGiftData.OnlineGiftData.getInstance().huoqu_jieshou_cishu();
        const gameConst = AL_GAME_HUA_GameConst.GameConst.getInstance();
        return gameConst.online_time_origin + receiveCount * gameConst.online_time_increase;
    }

    huoqu_zaixian_jiangli_shifou_jiesuo() {
        return AL_GAME_HUA_OnlineGiftData.OnlineGiftData.getInstance().huoqu_liwu_shifou_jiesuo();
    }

    shezhi_zaixian_jiangli_jiesuo(unlocked) {
        AL_GAME_HUA_OnlineGiftData.OnlineGiftData.getInstance().shezhi_liwu_shifou_jiesuo(unlocked);
        this.giftTime = this.huoqu_xuyao_shijian();
    }

    chuli_lingqu() {
        AL_GAME_HUA_OnlineGiftData.OnlineGiftData.getInstance().tianjia_jieshou_cishu();
        this.giftTime = 0;
    }

    huoqu_zaixian_jiangli_rule() {
        return AL_GAME_HUA_OnlineGiftData.OnlineGiftData.getInstance().huoqu_jieshou_cishu() === 0
            ? [1, 1, 1, 1, 100]
            : [2, 2, 2, 2, 200];
    }

    baocun_shijian_jilu() {
        // 保存时间记录的具体实现
    }

    huoqu_shengyu_shijian() {
        return this.huoqu_xuyao_shijian() - this.giftTime;
    }

    gengxin_shijian(elapsedTime) {
        if (this.huoqu_zaixian_jiangli_shifou_keyong()) {
            if (this.giftTime === -1) {
                this.giftTime = AL_GAME_HUA_OnlineGiftData.OnlineGiftData.getInstance().huoqu_shijian_jilu();
            }
            if (this.huoqu_zaixian_jiangli_shifou_jiesuo()) {
                this.giftTime = this.huoqu_xuyao_shijian();
                return;
            }
            if (this.giftTime < this.huoqu_xuyao_shijian()) {
                this.giftTime += elapsedTime;
                this.recordTime += elapsedTime;
                if (this.recordTime >= 10) {
                    this.baocun_shijian_jilu();
                }
            } else if (this.giftTime !== this.huoqu_xuyao_shijian()) {
                this.giftTime = this.huoqu_xuyao_shijian();
                if (!this.huoqu_zaixian_jiangli_shifou_jiesuo()) {
                    this.shezhi_zaixian_jiangli_jiesuo(true);
                }
                if (AL_GAME_HUA_OnlineGiftData.OnlineGiftData.getInstance().huoqu_shijian_jilu() !== this.giftTime) {
                    this.baocun_shijian_jilu();
                }
            }
        }
    }
}

// 导出类
exports.OnlineGiftConfig = OnlineGiftConfig;